<!--#layout("/common/container.html"){  -->
  <!-- 顶部 -->
<div class="layui-row">
    <div class="layui-col-md1"><img id="logo1" class="pointer" style="height: 70px;margin-left: 8px;" src="${ctxPath}/beautiful.jpg"></div>
</div>
  <form class="layui-form layui-form-pane" >
  <div class="layui-header header layui-bg-blue">
    <a href="javascript:;" class="layui-hide-xs"><div class="layui-logo lLogo">美妆商城后台管理系统</div></a>
    <a href="javascript:;" class="layui-hide-xs"><div class="fsSwitchMenu"><i class="iconfont icon-category"></i></div></a>



    <!-- 顶部菜单 -->
    <ul class="layui-nav layui-layout-left fsTopMenu" id="fsTopMenu" lay-filter="fsTopMenu">
      <!--#for(node in menus.children){  -->
      <li class="layui-nav-item ${nodeLP.first?'layui-this'} topLi" dataPid="${node.data.id}"><a href="javascript:;"><i class="layui-icon">${node.data.icon}</i>
      <!--#if(nodeLP.first){  -->
      <cite>${node.data.name}</cite>
      <!--#}else{  -->
      ${node.data.name}
      <!--#}  -->
      </a></li>
      <!--#} -->
    </ul>
    
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide-xs">
        <a href="javascript:;">
         	${session["core:user"].name}
        </a>
        <dl class="layui-nav-child">
          <dd id="showBaseInfoButton"><a href="javascript:;">基本资料</a></dd>
          <dd id="changeCompanyButton"><a href="javascript:;">${session["core:currentOrg"].name}</a>
          <dd id="changePasswordButton"><a href="javascript:;">修改密码</a>
          </dd>
        </dl>
      </li>
      <li class="layui-nav-item layui-hide-xs"><a href="${ctxPath}/logout.do"><i class="iconfont icon-tuichu"></i> 退出</a></li>
    </ul>
  </div>
  
  <div  id="selectCompany" 
  	style="padding: 50px;display:none;">
  	<div class="layui-row">
		<div class="layui-form-item">
			<select id="companyList"> 
			<!--#
			var allOrgs = session["core:orgs"];
			for(org in allOrgs){
				var checked = false;
				if(session["core:currentOrg"].id==org.id){
					checked=true;
				}
			 -->
		  	
		  	<option value="${org.id}" ${checked?"selected"}>${org.name}</option>
		  	<!--#}  -->
		  	</select>
  		</div>
 	 </div>
 	</div>


  <!-- 左边菜单 -->
  <div class="layui-side layui-bg-black lMenu">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree fsMenu lnMenu"  lay-filter="fsLeftMenu" id="fsLeftMenu">
      	<!--#
      	for(node in menus.children){  
      	var hasSite = true;//系统的第一个菜单默认显示
      	-->
      	<!--#for(subSystem in node.children){  -->
        <li class="layui-nav-item layui-nav-item menuLi" dataPid="${node.data.id}" style="display: none;">
          <a href="javascript:;" class="menuFont icon">${subSystem.data.name}</a>
          <dl class="layui-nav-child lnDl" style="background-color: #F6F6F6!important;">
          	<!--#for(menu in subSystem.children){  -->
          	<dd class="lnDd" ><a href="javascript:;" class="dMenuFont" menuId="${menu.data.id}" dataUrl="${ctxPath}${menu.data.accessUrl}"><i class="layui-icon">&#xe68e;</i>
          	${menu.data.name}
          	</a></dd>
            <!--#}  -->
           </dl>
        </li>
        <!--#}  -->
        <!--#}  -->
      </ul>
    </div>
  </div>

  <!-- 右边内容区域 -->
  <div class="layui-body layui-form rBody">
  	<div class="layui-tab layui-tab-card fsTab" lay-filter="fsTab" lay-allowClose="true">
  		
  		<!-- 菜单导航 -->
		<ul id="fsTab" class="layui-tab-title topMenu">
		    <li class="layui-this home" lay-id="0">首页</li>
		</ul>
        <!--tab标签-->
        <ul class="rightmenu">
            <li data-type="closethis">关闭当前</li>
            <li data-type="closeother">关闭其他</li>
            <!--<li data-type="closeall">关闭所有</li>-->
        </ul>
		
		<!-- 内容 -->
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
			<!--#include("/help.html"){}  -->
			</div>
		</div>
	</div>
  </div>
  </form>
<!--#}  -->
<style>
    /**右键菜单*/
    .rightmenu {
        position: absolute;
        top: 42px!important;
        width: 110px;
        z-index: 9999;
        display: none;
        background-color: #fff;
        padding: 2px;
        color: #333;
        border: 1px solid #eee;
        border-radius: 2px;
        cursor: pointer;
    }

    .rightmenu li {
        text-align: center;
        display: block;
        height: 30px;
        line-height: 32px;
    }

    .rightmenu li:hover {
        background-color: #1B598A;
        color: #fff;
    }
</style>

<script>

       // var websocket = null;
    // if('WebSocket' in window){
    //     websocket = new WebSocket("ws://localhost:9998/demo/websocket/1");
    // }else{
    //     alert("您的浏览器不支持websocket");
    // }
    // websocket.onerror = function(){
    //     setMessageInHtml("send error！");
    // }
    // websocket.onopen = function(){
    //     setMessageInHtml("connection success！")
    // }
    // websocket.onmessage  = function(event){
    //     setMessageInHtml(event.data);
    // }
    // websocket.onclose = function(){
    //     setMessageInHtml("closed websocket!")
    // }
    // window.onbeforeunload = function(){
    //     clos();
    // }
    // function setMessageInHtml(message){
    //     document.getElementById('message').innerHTML += message;
    // }
    // function clos(){
    //     websocket.close(3000,"强制关闭");
    // }
    // function send(){
    //     var msg = document.getElementById('text').value;
    //     websocket.send(msg);
    // }


    /**
     * 当前登入用户密码修改
     */
    var index;
    $("#changePasswordButton").click(function(){
        index = layer.open({
            type: 1,
            title:"密码修改",
            area: ['355px','260px'],
            id: 'LAY_layuipro', //设定一个id，防止重复弹出
            resize: false,
            moveType: 1, //拖拽模式，0或者1
            content:
                    '<div class="layui-form-item" style="margin-right: 50px;margin-top: 5px">'+
                        '<label class="layui-form-label">旧密码</label>'+
                        '<div class="layui-input-block">'+
                            '<input id="oldPassword" type="password" placeholder="请输入旧密码"class="layui-input">'+
                        '</div>'+
                    '</div>'+
                    '<div class="layui-form-item" style="margin-right: 50px">'+
                        '<label class="layui-form-label">新密码</label>'+
                        '<div class="layui-input-block">'+
                            '<input id="newPassword" type="password" placeholder="请输入新密码" class="layui-input">'+
                        '</div>'+
                    '</div>'+
                    '<div class="layui-form-item" style="margin-right: 50px">'+
                        '<label class="layui-form-label">再次输入</label>'+
                        '<div class="layui-input-block">'+
                            '<input id="newPassword2" type="password" placeholder="请再次输入新密码" class="layui-input">'+
                    '</div>'+
                    '</div>'+
                    '<div class="layui-form-item" style="margin: 10px">'+
                        '<div class="form-item-content">'+
                            '<button class="layui-btn" onclick="return fromPassword()" style="margin-left: 130px">提交</button>'+
                        '</div>'+
                    '</div>'
        });
    });

    /**
     * 验证旧密码
     */
    fromPassword  = function(){
        var oldPassword = $("#oldPassword").val();
        var newPassword = $("#newPassword").val();
        var newPassword2 = $("#newPassword2").val();
        if(oldPassword === null || oldPassword === ''){
            layer.msg("请输入旧密码");
            return false;
        }
        if(newPassword === null || newPassword === ''){
            layer.msg("请输入新密码");
            return false;
        }
        if(newPassword2 === null || newPassword2 === ''){
            layer.msg("请再次输入新密码");
            return false;
        }
        if (newPassword===oldPassword) {
            layer.msg("新密码不能与旧密码相同");
            return false;
        }
        if(newPassword !== newPassword2){
            layer.msg("密码不一致");
            return false;
        }
        $.ajax({
            url: Common.ctxPath + '/cms/appUser/changePassword2.json',
            type: "POST",
            data: {'oldPassword':oldPassword,'newPassword':newPassword},
            success: function (rsp) {
                var msg = rsp.msg;
                if (msg==="0") {
                    layer.msg("旧密码验证错误")
                }
                if (msg==="1"){
                    layer.close(index);
                    layer.msg("修改成功")
                }
            }
        });
    };

    /**
     * 查看基本资料
     */
    $("#showBaseInfoButton").click(function(){
        $.ajax({
            url : Common.ctxPath + '/cms/appUser/getBaseInfo.json',
            type : "GET",
            success : function (rsp) {
                var data = rsp.data;
                layer.msg('基本资料<br>' +
                    '<div style="text-align:left;margin-top: 5px">编号：'+data.code+'</div>' +
                    '<div style="text-align:left;margin-top: 5px">真实姓名：'+data.realName+'</div>' +
                    '<div style="text-align:left;margin-top: 5px">电话号码：'+data.tel+'</div>'
                    , {
                        time: 10000,
                        area:['250px'] ,
                        btn: ['关闭']
                    });
            }
        });
    });

</script>